import request from '@/utils/request'
// 下载导入模板
export function importTemplate() {
  return request({
    url: '/system/dataManagement/importTemplate',
    method: 'get'
  })
}

// 查询半成品列表
export function listSfproduct(query) {
  return request({
    url: '/sfproduct/sfproduct/list',
    method: 'get',
    params: query
  })
}

// 查询元件清单
export function listMaterials(sfpId) {
  return request({
    url: '/sfproduct/sfproduct/getMaterialVo/' + sfpId,
    method: 'get',
    params: sfpId
  })
}

// 查询半成品详细
export function getSfproduct(sfproductId) {
  return request({
    url: '/sfproduct/sfproduct/' + sfproductId,
    method: 'get'
  })
}

//查询原材料和半成品中间表信息
export function getMiddle(sfproductId,materialId) {
  return request({
    url: '/sfproduct/sfproduct/getMiddle/',
    method: 'get',
    params:{
      sfproductId:sfproductId,
      materialId:materialId
    }
  })
}

// 新增半成品
export function addSfproduct(data) {
  return request({
    url: '/sfproduct/sfproduct',
    method: 'post',
    data: data
  })
}

// 修改半成品
export function updateSfproduct(data) {
  return request({
    url: '/sfproduct/sfproduct',
    method: 'put',
    data: data
  })
}

// 新增原材料
export function addMaterials(data) {
  return request({
    url: '/sfproduct/sfproduct/addMaterials',
    method: 'post',
    data: data
  })
}

// 修改原材料
export function updateMaterials(data) {
  return request({
    url: '/sfproduct/sfproduct/updateMaterials',
    method: 'put',
    data: data
  })
}

// 删除半成品
export function delSfproduct(sfproductId) {
  return request({
    url: '/sfproduct/sfproduct/' + sfproductId,
    method: 'delete'
  })
}

// 删除元件菜单原材料
export function delMaterial(sfproductId,materialId) {
  return request({
    url: '/sfproduct/sfproduct/delMaterial/' + sfproductId + '/' + materialId,
    method: 'delete',
    params:{
      sfproductId:sfproductId,
      materialId:materialId
    }
  })
}

// 清空元件菜单原材料
export function overAgain(sfproductId) {
  return request({
    url: '/sfproduct/sfproduct/overAgain/' + sfproductId,
    method: 'delete',
    params:{
      sfproductId:sfproductId,
    }
  })
}

// 修改原材料
export function transmissionSfpID(sfproductId) {
  return request({
    url: '/sfproduct/sfproduct/transmissionSfpID',
    method: 'put',
    params:{
      sfproductId:sfproductId,
    }
  })
}
